﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Model;
using MsDAL;

namespace UIDesign
{
    public partial class FrmCopy : Form
    {
        Sys5a00DAL dal = new Sys5a00DAL();
        private string plistid = "";
        private string srclistid = "";
        private string size = "";

        public FrmCopy()
        {
        }

        public FrmCopy(string moduleName, string pageName, string size, string srclistid)
        {
            InitializeComponent();

            this.txtSource.Text = moduleName;
            this.txtSourcePage.Text = pageName;
            this.srclistid = srclistid;
            this.size = size;
        }

        private void picSelect_Click(object sender, EventArgs e)
        {
            FrmPageList pg = new FrmPageList("s");
            if (pg.ShowDialog() == DialogResult.OK)
            {
                Sys5a00 sv = pg.GetSelectedValue();
                if (sv.Pagename == this.txtSource.Text && sv.Ctlname == this.txtSourcePage.Text)
                {
                    MessageBox.Show("不能自己复制给自己！");
                    return;
                }

                txtTarget.Text = sv.Pagename;
                txtTargetPage.Text = sv.Ctlname;
                plistid = sv.Listid;
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            List<SqlApp> list = new List<SqlApp>();

            string success = dal.Copy(this.srclistid, this.plistid, this.txtSource.Text, this.size, this.txtSourcePage.Text);
            if (string.IsNullOrEmpty(success))
            {
                MessageBox.Show("复制成功！");
                IsSuccess = true;
                this.Close();
            }
            else 
            {
                MessageBox.Show(success);
            }
        }

        public bool OpResult
        {
            get { return IsSuccess; }
        }

        private bool IsSuccess = false;
    }
}
